package com.jxs.android.util;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class VersionHolder {
	static public interface OsVersion {
		public final static boolean IS_LESS_SDK_14 = (android.os.Build.VERSION.SDK_INT < 14) ? true : false;
		public static int osVersion = android.os.Build.VERSION.SDK_INT;
	}

	public static String getVersionName(Context context) {
		// 获取packagemanager的实例
		PackageManager packageManager = context.getPackageManager();
		// getPackageName()是你当前类的包名，0代表是获取版本信息
		PackageInfo packInfo = null;
		try {
			packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
		} catch (NameNotFoundException e) {
			packInfo = new PackageInfo();
			packInfo.versionName = "";
		}
		return packInfo.versionName;
	}
}